package com.cl.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.cl.pojo.Department;
import com.cl.pojo.Post;
import com.cl.service.impl.PostServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
public class PostController {
    @Autowired
    PostServiceImpl postService;

    @ResponseBody
    @RequestMapping(value = "/plist",produces = "application/json;charset=utf-8")
    public String query_PList(){
        List<Post> list = postService.queryAll();
        int count=list.size();

        Map<String,Object> map=new HashMap<>();
        map.put("code",0);
        map.put("msg","");
        map.put("count",count);
        map.put("data",list);

        return JSON.toJSONString(map);
    }
}
